
// 日志输出到安装路径下
const logger = require('electron-log')


function loggerInit() {


    logger.transports.file.level = 'debug'
// logger.transports.file.maxSize = 1002430
    logger.transports.file.maxSize = 10485760   // 文件最大限制为 10M = 10*1024*1024
    logger.transports.file.format = '[{y}-{m}-{d} {h}:{i}:{s}.{ms}] [{level}]{scope} {text}'
    logger.transports.file.fileEncoding = 'UTF-8'; // 指定文件编码格式为 UTF-8


    let date = new Date()

    let mm = date.getMonth() + 1
    if (mm < 10) {
        mm = "0" + mm
    }

    let dd = date.getDate()
    if (dd < 10) {
        dd = "0" + dd
    }

    date = date.getFullYear() + '-' + mm + "-" + dd

    const isDevelopment = process.env.NODE_ENV === 'development'
    const logFileName = 'client.' + date + '.log';
    const logFilePath = isDevelopment ? "./server/logs/" : "./resources/server/logs/"



    if(myWindows.systemType==='Windows'){
        // 日志输出到安装路径下
        logger.transports.file.resolvePath = () => logFilePath + logFileName; // 安装目录下的 \logFile\文件下
    }

    logger.info('日志初始化完成')

}

exports.loggerInit=loggerInit




